package com.ruoyi.yljf.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum yljfEnums {

    /**
     * 系统是否
     */

    Y("Y", "免费"),
    N("N", "收费"),

    /**
     * 线上/线下
     */
    ONLINE("online", "线上"),
    OFFLINE("offline", "线下"),

    /**
     * course_type  课程类型枚举
     */
    AUDIO("audio", "音频"),
    VIDEO("video", "视频"),
    //笔记类型需要的枚举--video和book
    BOOK("book", "书籍"),
//    活动-空间中间表枚举  book--course--paper
    COURSE("course","课程"),
    COURSEWARE("courseware","课件"),
    PAPER("paper","试卷"),
    ARTICLE("article","文章"),
    QUESTION("question","问题"),
    /**
     * user_type   课程新增时用户类型
     */
    USER("user", "用户"),
    PHARMACY("pharmacy", "中医馆"),
    ADMIN("admin", "管理后台"),

    /**
     * course_grade 课程等级
     */
    PRIMARY("primary", "入门"),
    INITIAL("initial", "初级"),
    INTERMEDIATE("intermediate", "中级"),
    ADVANCED("advanced", "高级"),

    /**
     * user_identity 用户身份
     */
    ATHLETE("athlete", "中医爱好者"),
    DOCTOR("doctor", "中医从业者"),
    STUDENT("student", "中医专业学生"),
    WESTERN("western", "西学中"),

    /** 笔记类型 */
    NOTICE_TYPE_DRUG("drug","药材"),
    NOTICE_TYPE_COURSE("course","课程"),
    NOTICE_TYPE_JINGFANG("jingfang","经方"),
    NOTICE_TYPE_MEDIAL("medical","医案"),


    /** 收藏类型 */
    COLLECT_TYPE_DRUG("drug","药材"),
    COLLECT_TYPE_COURSE("course","课程"),
    COLLECT_TYPE_JINGFANG("jingfang","经方"),
    COLLECT_TYPE_MEDICAL("medical","医案"),
    COLLECT_TYPE_QUESTION("question","试题"),
    /** 字典类型 */
    COURSE_TYPE("course_type","课程类型"),
    SECONDARY_TYPE("secondary_type","首页精选课程二级分类"),
    REPORT_TYPE("report_type","举报类型"),

    /**
     * 未知枚举报错
     */
    UNKNOWN("error", "错误数据");


    private final String code;
    private final String desc;



    public String code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    /**
     * 通过code获取desc
     *
     * @param code code
     * @return desc
     */
    public static String descOfCode(String code) {

        return Arrays.stream(values())
                .filter(it -> it.code().equalsIgnoreCase(code))
                .findFirst()
                .map(a -> a.desc)
                .orElse(null);
    }

    public static String codeOfDes(String des) {

        return Arrays.stream(values())
                .filter(it -> it.desc().equalsIgnoreCase(des))
                .findFirst()
                .map(a -> a.code)
                .orElse(null);
    }

    /**
     * 根据枚举值返回 code
     *
     * @param yljfEnums 枚举值
     * @return 对应的 code
     */
    public static String getCodeByEnum(yljfEnums yljfEnums) {

        if (yljfEnums == null) {
            return UNKNOWN.getCode(); // 如果传入的枚举值为 null，返回默认值 "error"
        }
        return yljfEnums.getCode();

    }


}
